package com.qf.dao.impl;

import com.qf.dao.UserDao;
import com.qf.pojo.Admin;
import com.qf.utils.DruidUtil;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;

import java.util.List;

/**
 * @program: myproject
 * @description:
 * @author: mrsheng
 * @create: 2022-09-26 17:30
 **/


public class UserDaoImpl implements UserDao {
    private JdbcTemplate jdbcTemplate=new JdbcTemplate(DruidUtil.getDataSource());

    @Override
    public List<Admin> login(Admin admin) {
       String sql="select * from admin where username=? and password=?";
        List<Admin> query = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(Admin.class), admin.getUsername(), admin.getPassword());
            return query;

    }

    //查询所有
    @Override
    public List<Admin> findAll() {
        String sql="select * from admin ";
        List<Admin> query = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(Admin.class));
            return query;
    }
}
